import request from '@/axios'
import { SysTaskDetailVo, SysTaskEditQo, SysTaskListVo, SysTaskSearchQo } from './types'
import { BaseDeleteQo } from '@/base/api/BaseQo'
import { KeyLabelValueVo } from '@/base/api/KeyLabelValueVo'

export const sysTaskPageApi = (data: SysTaskSearchQo): Promise<IResponse<Array<SysTaskListVo>>> => {
  return request.post({ url: '/sysTask/page.adw', data })
}

export const sysTaskDetailApi = (id: number): Promise<IResponse<SysTaskDetailVo>> => {
  const data = { id }
  return request.post({
    url: '/sysTask/detail.adw',
    data
  })
}

export const sysTaskAddApi = (data: SysTaskEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysTask/add.adw', data })
}

export const sysTaskUpdateApi = (data: SysTaskEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysTask/update.adw', data })
}

export const sysTaskDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysTask/delete.adw', data })
}

export const sysTaskRunImmediatelyApi = (data: SysTaskEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysTask/runImmediately.adw', data })
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]
export const selectSysTaskNameListApi = (
  data: SysTaskSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysTask/selectNameList.adw', data })
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
